# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.


from odoo import api, fields, models
from odoo.exceptions import AccessDenied, UserError
from odoo.http import request


class ResUsers(models.Model):
    _inherit = 'res.users'

    def _check_credentials(self, password, env):
        try:
            return super(ResUsers, self)._check_credentials(password, env)
        except AccessDenied:
            if hasattr(request, 'from_wechat'):
                return
                # passwd_allowed = env['interactive'] or not self.env.user._rpc_api_keys_only()
                # if passwd_allowed and self.env.user.active:
                #     res = self.sudo().search([('id', '=', self.env.uid), ('oauth_access_token', '=', password)])
                #     if res:
            raise
